package com.digitalart.site.section.subsectiontype.subsectionnav {
	import flash.text.TextFormat;
	import flash.text.TextField;

	import com.digitalart.site.commons.TextFormatter;

	import flash.display.Sprite;

	/**
	 * @author johan.chaves
	 */
	public class NavItem extends Sprite {
		private var _isSelected : Boolean;
		private var _textField : TextField;
		private var _id : int;
		
		
		/**********************************Constructor*************************/
		public function NavItem(id : int,text : String) {
			
			this.id = id;
			textField = new TextField();
			textField.htmlText = text;
			textField.textColor = 0x006600;
			TextFormatter.setTextFormat(textField);							
			addTextFieldContainer();
		}	
		
		/**********************************************************************/

		/**********************************Methods*************************/
		
		private function addTextFieldContainer() : void {
			
			var textFieldContainer : Sprite = new Sprite();
			textFieldContainer.addChild(textField);
			textFieldContainer.buttonMode = true;
			textFieldContainer.mouseChildren = false;			
			addChild(textFieldContainer);
		}
		
		/**********************************************************************/
		/**************************Getters & Setters***************************/
		
		public function setTextColorSelected():void{
						
			textField.textColor = 0xCED728;
			var tf : TextFormat = new TextFormat();
			tf.underline = true;
			textField.setTextFormat(tf);
		}
		
		public function setTextColorUnSelected():void{
			
			textField.textColor = 0x006600;
			var tf : TextFormat = new TextFormat();
			tf.underline = false;
			textField.setTextFormat(tf);					
		}
		
		public function setTextColorOnRollOver():void{
			textField.textColor = 0xCED728;
		}
		
		public function setTextColorOnRollOut():void{
			
			if(!isSelected){
				textField.textColor = 0x006600;
				var tf : TextFormat = new TextFormat();
				tf.underline = false;
				textField.setTextFormat(tf);
			}							
		}
		
		public function get isSelected() : Boolean {
			return _isSelected;
		}
		
		public function set isSelected(isSelected : Boolean) : void {
			_isSelected = isSelected;
		}
		
		public function get textField() : TextField {
			return _textField;
		}
		
		public function set textField(textField : TextField) : void {
			_textField = textField;
		}
		
		public function get id() : int {
			return _id;
		}
		
		public function set id(id : int) : void {
			_id = id;
		}				

	}
}
